function createEventSource(url, options = {}) {
    const eventSource = new EventSource(url);
    let retryCount = 0;
    eventSource.onerror = () => {
        if (retryCount++ > 10) {
            //eventSource.close(); // 超过10次重试后主动关闭
        }
    };

    // 新增事件监听器
    eventSource.addEventListener('open', options.onOpen);
    eventSource.addEventListener('message', options.onMessage);
    eventSource.addEventListener('error', options.onError);

    // 新增销毁方法
    eventSource.destroy = function () {
        eventSource.close();
        eventSource.removeEventListener('open', options.onOpen);
        eventSource.removeEventListener('message', options.onMessage);
        eventSource.removeEventListener('error', options.onError);
    };

    // 返回EventSource对象
    return eventSource;
}